//
//  UIBarButtonItem+DKExtension.m
//  BS1
//
//  Created by 丁侃 on 16/4/24.
//  Copyright © 2016年 丁侃. All rights reserved.
//

#import "UIBarButtonItem+DKExtension.h"

@implementation UIBarButtonItem (DKExtension)
+(UIBarButtonItem *) dk_itemWithTarget:(id)target ation:(SEL) action ImageNameNormal:(NSString *) imageNameN imageNameHighlighted:(NSString *)imageNameH
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:imageNameN] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:imageNameH] forState:UIControlStateHighlighted];
    
    [btn sizeToFit];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[UIBarButtonItem alloc]initWithCustomView:btn];
}


+(UIBarButtonItem *) dk_itemWithTarget:(id)target ation:(SEL) action ImageNameNormal:(NSString *) imageNameN imageNameSelected:(NSString *)imageNameS
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:imageNameN] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:imageNameS] forState:UIControlStateSelected];
    
    [btn sizeToFit];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[UIBarButtonItem alloc]initWithCustomView:btn];
}


+(UIBarButtonItem *)dk_itemWithTarget:(id)target ation:(SEL) action ImageNameNormal:(NSString *) imageNameN imageNameHighlighted:(NSString *)imageNameH title:(NSString *)title titleNormalColor:(UIColor *) ColorN titleHighlightedColor:(UIColor *) ColorH
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:imageNameN] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:imageNameH] forState:UIControlStateHighlighted];
    [btn setTitle:title forState:UIControlStateNormal];
    [btn setTitleColor:ColorN forState:UIControlStateNormal];
    [btn setTitleColor:ColorH forState:UIControlStateHighlighted];
    [btn sizeToFit];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[UIBarButtonItem alloc]initWithCustomView:btn];
    
}

@end
